<?php
include_once("functions/db_manipulate.php");

if (!init()) {
    redirect("login.php");
}

$usersSet = searchUsers($_POST['user']);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Поиск пользователей</title>
    <link rel="stylesheet" href="css/navigation.css">
    <link rel="stylesheet" type="text/css" href="css/square.css">
    <link rel="stylesheet" type="text/css" href="css/menu.css">
    <link rel="stylesheet" type="text/css" href="css/common.css">
    <link rel="stylesheet" type="text/css" href="css/dialogs.css">
    <script src="resources/jquery.js"></script>
    <meta charset="UTF-8">
</head>

<body class="body">
<?php
include_once("menu.php");
?>

<div id="square">
    <div class="dialogdiv">
        <div class="dialogheader">
            Результаты поиска:
        </div>
        <form action="search_users.php" accept-charset="UTF-8" method="post" id="userform">
            <div>
                Поиск пользователя: <input type="text" maxlength="20" name="user" id="textarea"/>

                <div class="searchbutton" onclick="$('#userform').submit()">
                    Поиск
                </div>
            </div>
        </form>
        <?php

        while ($user = mysql_fetch_assoc($usersSet)) {
            ?>

            <div class="dialogcontentdiv" onclick="location.href='conversation_check.php?uid=<?= $user['id'] ?>'">
                <div class="dialog">
                    <div class="dialogcontentheader">
                        <?= $user['nick'] ?>
                    </div>
                    <div class="sectioninfo">
                        <div class="sectioninfodiv">
                            Почта: <?= $user['email'] ?>
                        </div>
                        <div class="sectioninfodiv">
                            Рейтинг: <?= $user['rating'] ?>
                        </div>
                        <div class="sectioninfodiv">
                            Сообщений: <?= $user['messages'] ?>
                        </div>
                    </div>
                </div>
            </div>
        <?php
        }
        ?>

    </div>
</div>

<?php
include_once("navigation.html");
?>
</body>
</html>
